package com.cloud.wms.ui.inside.entity;

import android.os.Parcel;

import com.cloud.wms.ui.main.entity.BatchEntity;
import com.cloud.wms.ui.main.entity.CommodityEntity;
import com.cloud.wms.ui.main.entity.PosEntity;
import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;


/**
 * @Author:Chen
 * @Date: 2021-03-30 15:55
 * @Description:
 */
public class ReplenishCommodityEntity extends CommodityEntity {
    /**
     * commodityID : 0
     * barCode : string
     * commodityCode : string
     * commodityName : string
     * totalAmount : 0
     * inventoryAmount : 0
     * memberID : 0
     * memberNo : string
     * commodityCodeList : ["string"]
     */

    private int factDownAmount;
    private int planDownAmount;
    private int planUpAmount;
    private int factUpAmount;
    private long destPosID;
    private String destPosCode;
    private boolean downStatus;
    private boolean upStatus;
    private List<PosEntity> recommendPoslst;
    @SerializedName("productBatchlst")
    private List<BatchEntity> downBatchList = new ArrayList<>();
    private List<BatchEntity> upBatchList = new ArrayList<>();

    public long getDestPosID() {
        return destPosID;
    }

    public void setDestPosID(long destPosID) {
        this.destPosID = destPosID;
    }

    public String getDestPosCode() {
        return destPosCode;
    }

    public void setDestPosCode(String destPosCode) {
        this.destPosCode = destPosCode;
    }

    public List<BatchEntity> getUpBatchList() {
        return upBatchList;
    }

    public void setUpBatchList(List<BatchEntity> upBatchList) {
        this.upBatchList.clear();
        if (upBatchList != null) {
            this.upBatchList.addAll(upBatchList);
        }
    }

    public List<BatchEntity> getDownBatchList() {
        return downBatchList;
    }

    public void setDownBatchList(List<BatchEntity> downBatchList) {
        this.downBatchList.clear();
        if (downBatchList != null) {
            this.downBatchList.addAll(downBatchList);
        }
    }

    public List<PosEntity> getRecommendPoslst() {
        if (recommendPoslst == null)
            return new ArrayList<>();
        return recommendPoslst;
    }

    public String getFirstRecommendPosCode() {
        if (recommendPoslst == null || recommendPoslst.isEmpty()) {
            return "";
        }
        if (recommendPoslst.get(0) == null) {
            return "";
        }
        return recommendPoslst.get(0).getPosCode();
    }

    public void setRecommendPoslst(List<PosEntity> recommendPoslst) {
        this.recommendPoslst = recommendPoslst;
    }

    public int getFactDownAmount() {
        return factDownAmount;
    }

    public void setFactDownAmount(int factDownAmount) {
        this.factDownAmount = factDownAmount;
    }

    public int getPlanDownAmount() {
        return planDownAmount;
    }

    public void setPlanDownAmount(int planDownAmount) {
        this.planDownAmount = planDownAmount;
    }

    public int getPlanUpAmount() {
        return planUpAmount;
    }

    public void setPlanUpAmount(int planUpAmount) {
        this.planUpAmount = planUpAmount;
    }

    public int getFactUpAmount() {
        return factUpAmount;
    }

    public void setFactUpAmount(int factUpAmount) {
        this.factUpAmount = factUpAmount;
    }

    public boolean isDownStatus() {
        return downStatus;
    }

    public void setDownStatus(boolean downStatus) {
        this.downStatus = downStatus;
    }

    public boolean isUpStatus() {
        return upStatus;
    }

    public void setUpStatus(boolean upStatus) {
        this.upStatus = upStatus;
    }

    public ReplenishCommodityEntity() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeInt(this.factDownAmount);
        dest.writeInt(this.planDownAmount);
        dest.writeInt(this.planUpAmount);
        dest.writeInt(this.factUpAmount);
        dest.writeLong(this.destPosID);
        dest.writeString(this.destPosCode);
        dest.writeByte(this.downStatus ? (byte) 1 : (byte) 0);
        dest.writeByte(this.upStatus ? (byte) 1 : (byte) 0);
        dest.writeTypedList(this.recommendPoslst);
        dest.writeTypedList(this.downBatchList);
        dest.writeTypedList(this.upBatchList);
    }

    protected ReplenishCommodityEntity(Parcel in) {
        super(in);
        this.factDownAmount = in.readInt();
        this.planDownAmount = in.readInt();
        this.planUpAmount = in.readInt();
        this.factUpAmount = in.readInt();
        this.destPosID = in.readLong();
        this.destPosCode = in.readString();
        this.downStatus = in.readByte() != 0;
        this.upStatus = in.readByte() != 0;
        this.recommendPoslst = in.createTypedArrayList(PosEntity.CREATOR);
        this.downBatchList = in.createTypedArrayList(BatchEntity.CREATOR);
        this.upBatchList = in.createTypedArrayList(BatchEntity.CREATOR);
    }

    public static final Creator<ReplenishCommodityEntity> CREATOR = new Creator<ReplenishCommodityEntity>() {
        @Override
        public ReplenishCommodityEntity createFromParcel(Parcel source) {
            return new ReplenishCommodityEntity(source);
        }

        @Override
        public ReplenishCommodityEntity[] newArray(int size) {
            return new ReplenishCommodityEntity[size];
        }
    };
}
